package org.example.hellogooglemaps;

public class Coordinata{
	private int gradi;
	private int primi;
	private float secondi;
	
	//costruttori
	public Coordinata(){
		
	}
	public Coordinata(int gradi, int primi, float secondi){
		this.gradi=gradi;
		this.primi=primi;
		this.secondi=secondi;		
	}

	public int getGradi(){
		return this.gradi;		
	}
	public int getPrimi(){
		return this.primi;
	}
	public float getSecondi(){
		return this.secondi;
	}
	public double getDouble(){
		return gradi+(float)primi/60+(float)secondi/3600;
	}
	public int getIntCoordinata(){
		return (int) ((gradi+(float)primi/60+(float)secondi/3600)*1000000);
	}
	public Coordinata getCentro(Coordinata cext){
	float minPrimi;
	float minSecondi;	
	float minGradi;
	if(this.primi>=cext.getPrimi()){minPrimi=cext.getPrimi();}
	else{minPrimi=this.primi;}
	if(this.secondi>=cext.getSecondi()){minSecondi=cext.getSecondi();}
	else{minSecondi=this.secondi;}
	if(this.gradi>=cext.getGradi()){minGradi=cext.getGradi();}
	else{minGradi=this.gradi;}
	Coordinata c = new Coordinata((int)(minPrimi+Math.abs((this.primi-cext.primi)/2)),(int)(minSecondi+Math.abs((this.secondi-cext.secondi)/2)),(float)(minGradi+Math.abs((this.gradi-cext.gradi)/2 ))); 	
	return c;
	}



}